home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
001-025
/
002
/
make
/
sys.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-13
|
1KB
|
59 lines
/*
* Routines which provide a single entry point to system routines,
* for easier debugging and porting.
*/
#include <stdio.h>
#include "make.h"
/*
* The system calls malloc()/calloc() really return a pointer suitable
* for use to store any object (satisfies worst case alignment
* restrictions). As such, it should really have been declared as
* anything BUT "char *".
*
* Also, this gives us the opportunity to verify that the memory
* allocator really does align things properly.
*
* Note that we choose to make calloc () the standard memory
* allocator, rather than malloc (), because it has a potentially
* bigger "bite" (total is product of two ints, rather than a
* single int).
*/
long *Calloc (nelem, elsize)
unsigned int nelem;
unsigned int elsize;
{
extern char *calloc ();
long *newmem;
long total;
DBUG_ENTER ("malloc");
DBUG_4 ("mem1", "allocate %u elements of %u bytes", nelem, elsize);
DBUG_3 ("mem2", "total of %ul bytes", total = nelem * elsize);
newmem = (long *) calloc (nelem, elsize);
if ((((int)newmem) % 4) != 0) {
fprintf (stderr, "urk -- Calloc screwed up!\n");
}
DBUG_3 ("mem", "allocated at %x", newmem);
DBUG_RETURN (newmem);
}
#ifdef AMIGA
int system (cmd)
char *cmd;
{
int status = -1;
extern int Execute ();
DBUG_ENTER ("system");
if (Execute (cmd, 0 ,0)) {
status = 0; /* Really should get exit status! */
}
DBUG_RETURN (status);
}
#endif /* AMIGA */